package com.game.majiang.vo;

import java.sql.Types;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.game.server.db.Parameter;
import com.game.server.db.ParameterType;
import com.game.server.db.SqlHelper;
import com.game.server.db.SqlHelperwrite;

public class DailyLandingGiftVo {

	/**
	 * 添加一跳登陆赠送 老板卡 或者  积分 的日志
	 * */
	public static void addGiftLog(int userid,int shuliang,int leixing)
	{
		String cmdText = "insert into dailyLanding_gift(userid,shuliang,leixing,gifttime)values(?,?,?,now())";
		Parameter p1 = new Parameter(Types.INTEGER, userid, ParameterType.Input);
		Parameter p2 = new Parameter(Types.INTEGER, shuliang, ParameterType.Input);
		Parameter p3 = new Parameter(Types.INTEGER, leixing, ParameterType.Input);
		SqlHelperwrite.execute(cmdText,p1,p2,p3);
	}
	
	/**
	 * 查询 当天 是否赠送 了 老板卡 或者 积分
	 * */
	public static int queryIsGift(int _uid,int _type){
		
		Date date = new Date();
		 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		 String str =sdf.format(date);
		String starttime = str+" 00:00:00";
		String endtime = str+" 23:59:59";
		String cmdText = "SELECT count(id) FROM dailyLanding_gift WHERE userid=? AND leixing = ? AND createtime >= ? AND createtime <= ?";
		Parameter p1 = new Parameter(Types.INTEGER, _uid, ParameterType.Input);
		Parameter p2 = new Parameter(Types.INTEGER, _type, ParameterType.Input);
		Parameter p3 = new Parameter(Types.VARCHAR, starttime, ParameterType.Input);
		Parameter p4 = new Parameter(Types.VARCHAR, endtime, ParameterType.Input);
	   Object obj =SqlHelper.execScalar(cmdText, p1,p2,p3,p4);
		if(obj!=null){
			return ((Long)obj).intValue();
		}
		return 0;
		
		
		
	}
	
}
